package com.wfh.aigenerator.ratelimter.config;

import lombok.Data;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Title: RedissonConfig
 * @Author wangfenghuan
 * @Package com.wfh.aigenerator.ratelimter.config
 * @Date 2025/8/13 21:30
 * @description:
 */
@Configuration
@ConfigurationProperties(prefix = "redisson")
@Data
public class RedissonConfig {

    private String host;

    private int port;

    private String password;

    private int database;

    @Bean
    public RedissonClient redissonClient(){
        Config config = new Config();
        config.useSingleServer()
                .setAddress("redis://" + host + ":" + port)
                .setPassword(password)
                .setDatabase(database);
        return Redisson.create(config);
    }
}
